package zimoch.mordheim;
import java.io.File;

import zimoch.mordheim.UnitComplexType;
import zimoch.mordheim.UnitComplexType.Factory;
import zimoch.mordheim.UnitComplexType.Psychology.Psycho;
import zimoch.mordheim.impl.UnitComplexTypeImpl;
import zimoch.utils.*;
public class Unit {

	boolean isAttacking;
	boolean isCharge;
	boolean canShoot;
	boolean canRun;
	boolean canCastSpells;
	
	UnitComplexTypeImpl unit;

	Unit(UnitComplexTypeImpl inUnit)
	{
		this.unit._set(inUnit._copy());
	}
	
	public boolean isAttacking() {
		return isAttacking;
	}


	public void setAttacking(boolean isAttacking) {
		this.isAttacking = isAttacking;
	}


	public boolean isCharge() {
		return isCharge;
	}


	public void setCharge(boolean isCharge) {
		this.isCharge = isCharge;
	}


	public boolean isCanShoot() {
		return canShoot;
	}


	public void setCanShoot(boolean canShoot) {
		this.canShoot = canShoot;
	}


	public boolean isCanRun() {
		return canRun;
	}


	public void setCanRun(boolean canRun) {
		this.canRun = canRun;
	}


	public boolean isCanCastSpells() {
		return canCastSpells;
	}


	public void setCanCastSpells(boolean canCastSpells) {
		this.canCastSpells = canCastSpells;
	}


	public UnitComplexTypeImpl getUnit() {
		return unit;
	}


	public void setUnit(UnitComplexTypeImpl unit) {
		this.unit = unit;
	}
	
	public boolean isPsychologyType(String type)
	{
		for (int i=0 ; i < this.unit.getPsychology().getPsychoArray().length  ; i++)
		{
			if(unit.getPsychology().getPsychoArray()[i].getType().toLowerCase() == type.toLowerCase())
			{
				return true;
			}
				
		}
		return false;
	}
		
	public boolean leadershipTest()
	{
		int fstUnit2d6;
			
		fstUnit2d6 = Engine.doThrow2d6();
		
		if (this.unit.getLeadership() >= fstUnit2d6)
		{
			Util.print("Test na leadership udany");
			return true;
		}
		else
		{
			Util.print("Nieudany test na leadership");
			return false;
		}
	}
	
	public int getNumberOfAttRgtHand()
	{
		int number = 0;
		for( int i=0 ; i < this.unit.getEquipment().getHeandweaponArray().length ; i++)
		
		{
			if( this.unit.getEquipment().getHeandweaponArray()[i].getEquip() == Types.RIGHTHAND)
			{
				number++;
			}
		}
		
		return number;
		
	}
	public int getNumberOfAddAtts()
	{
		int number = 0;
		for( int i=0 ; i < this.unit.getEquipment().getHeandweaponArray().length ; i++)
		
		{
			if( this.unit.getEquipment().getHeandweaponArray()[i].getEquip() == Types.LEFTHAND )
			{
				number++;
			}
		}
		
		return number;
		
	}
	
	
}
	


	